The Hello World
program is the first one you will write, in every environment, in any language!
Click into the code cell below so that it is surrounded by a box. Then press the "play" button in the toolbar above, the one that looks like a triangle. It will run the code.
In [ ]:
# The first step is to import the parts of code that let our Python
# program talk to Minecraft:
import mcpi.minecraft as minecraft
import mcpi.block as block
# Next, we create an object named `world`. This object is what we
# use to talk to the Minecraft server.
world = minecraft.Minecraft.create()
# And then we post a message to chat
world.postToChat("Hello Minecraft!")
Now, switch back to your Minecraft game and open the "chat" by pressing the "T" key. Check if you see the "Hello Minecraft!
" message we sent from Python. If you don't see it, click into the code cell above and press the "play" button again. Sometimes the chat message won't appear if you weren't connected to the game when the script was run.